﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace start_daemon
{
    public partial class frmEjecutar : Form
    {
        public frmEjecutar()
        {
            InitializeComponent();
        }

        private void btn_ejecuta_Click(object sender, EventArgs e)
        {
            Process cmd = new Process();

            cmd.StartInfo.FileName = "cmd.exe";
            cmd.StartInfo.RedirectStandardInput = true;
            cmd.StartInfo.RedirectStandardOutput = true;
            cmd.StartInfo.CreateNoWindow = true;
            cmd.StartInfo.UseShellExecute = false;

            cmd.Start();
            string directorio = textBox1.Text;

            cmd.StandardInput.WriteLine(directorio);
            cmd.StandardInput.Flush();
            cmd.StandardInput.Close();
        }

        private void time_damon_Tick(object sender, EventArgs e)
        {
            //System.Diagnostics.ProcessStartInfo f = new ProcessStartInfo();            

            //foreach(System.Diagnostics.TraceListener fg in  System.Diagnostics.Debug.Listeners)
            //{
               
            //}
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string error = "";
            try
            {
                int num = Convert.ToInt32("03");
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                StreamWriter st = new StreamWriter("error.txt");
                MessageBox.Show(error);
                st.Write(error);
                st.Close();
            }
        }
        void Proceso_()
        {
            MessageBox.Show(Path.GetFileNameWithoutExtension("error.txt"));
            Process proceso = new Process();
            //proceso = Process.GetProcessesByName("");
            foreach (Process p in Process.GetProcesses("plus-ew"))
            {
                if (p.ProcessName.Equals("Control de acceso"))
                    p.Kill();
                else
                    listBox1.Items.Add(p.ProcessName);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Proceso_();
        }
    }
}
